{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "kxu1Gfhx1pHg"
   },
   "source": [
    "<a href=\"https://colab.research.google.com/github/jeffheaton/app_generative_ai/blob/main/t81_559_class_12_1_prompt_engineering.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "ZbNbAV281pHh"
   },
   "source": [
    "# T81-559: Applications of Generative Artificial Intelligence\n",
    "**Module 12: Prompt Engineering**\n",
    "* Instructor: [Jeff Heaton](https://sites.wustl.edu/jeffheaton/), McKelvey School of Engineering, [Washington University in St. Louis](https://engineering.wustl.edu/Programs/Pages/default.aspx)\n",
    "* For more information visit the [class website](https://sites.wustl.edu/jeffheaton/t81-558/)."
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {
    "id": "HwnvSYEQ1pHi"
   },
   "source": [
    "# Module 12 Material\n",
    "\n",
    "Module 12: Prompt Engineering\n",
    "\n",
    "* **Part 12.1: Intro to Prompt Engineering** [[Video]](https://www.youtube.com/watch?v=p8q2kFhyX3M&ab_channel=JeffHeaton) [[Notebook]](t81_559_class_12_1_prompt_engineering)\n",
    "* Part 12.2: Few Shot and Chain of Thought [[Video]](https://www.youtube.com/watch?v=Bj-zOiqpp6g&ab_channel=JeffHeaton) [[Notebook]](t81_559_class_12_2_fewshot_cot.ipynb)\n",
    "* Part 12.3: Persona and Role Patterns [[Video]](https://www.youtube.com/watch?v=uD9z3LFw7nA&ab_channel=JeffHeaton) [[Notebook]](t81_559_class_12_3_persona.ipynb)\n",
    "* Part 12.4: Question, Refinement and Verification Patterns [[Video]](https://www.youtube.com/watch?v=UF0gN79hg4g&ab_channel=JeffHeaton) [[Notebook]](t81_559_class_12_4_refinement_eval.ipynb)\n",
    "* Part 12.5: Content Creation and Structured Prompt Patterns [[Video]](https://www.youtube.com/watch?v=PPNnTDfKjPE&ab_channel=JeffHeaton) [[Notebook]](t81_559_class_12_5_create.ipynb)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "v2MPPX0c1pHi"
   },
   "source": [
    "# Part 12.1: Intro to Prompt Engineering\n",
    "\n",
    "In the dynamic world of life insurance, professionals are increasingly turning to artificial intelligence to enhance client interactions, streamline processes, and access information quickly. Prompt engineering is the art of crafting effective inputs (prompts) to guide language models like GPT-4 in generating useful and accurate outputs. Mastering prompt engineering can empower life insurance professionals to obtain precise information, create compelling client communications, and make informed decisions.\n",
    "\n",
    "This guide will delve into key aspects of prompt engineering tailored for the life insurance industry, complete with practical examples to help you get the most out of AI language models.\n",
    "\n",
    "### Provide Specific and Complete Instructions\n",
    "\n",
    "Specific and complete instructions enable the AI model to understand exactly what you need, reducing ambiguity and enhancing the relevance of the response.\n",
    "\n",
    "Ineffective Prompt Example:\n",
    "\n",
    "```Explain the types of life insurance policies```\n",
    "\n",
    "Effective Prompt Example:\n",
    "\n",
    "```As a life insurance professional, summarize the key differences between whole life insurance and term life insurance, focusing on benefits, duration, and typical customer profiles.```\n",
    "\n",
    "The effective prompt clearly specifies the role, the exact information needed, and the aspects to focus on, ensuring the AI provides a detailed and relevant response.\n",
    "\n",
    "### Explain What to do in Exception Situation\n",
    "\n",
    "Importance: By anticipating potential exceptions and instructing the model on how to handle them, you can avoid incomplete or misleading answers.\n",
    "\n",
    "```List the top five life insurance providers in the U.S. based on customer satisfaction. If current data is unavailable, please provide the most recent statistics from reputable sources and mention the year of the data.```\n",
    "\n",
    "This prompt tells the AI what to do if up-to-date information isn't available, ensuring you still receive valuable data with proper context.\n",
    "\n",
    "### Explain Output Format\n",
    "\n",
    "Defining the desired output format makes the information easier to use and can facilitate integration with other documents or presentations.\n",
    "\n",
    "```Create a comparison table of term life and whole life insurance policies, including columns for 'Policy Features,' 'Advantages,' and 'Ideal For.' Present the information in markdown format.```\n",
    "\n",
    "By specifying the format (a markdown table) and the exact columns needed, the AI can generate a structured and professional-looking comparison table ready for client presentations or internal use.\n",
    "\n",
    "### Ask for Suggestions on your Prompt\n",
    "\n",
    "Requesting feedback helps refine your prompts, leading to better results and enhancing your prompt engineering skills.\n",
    "\n",
    "```I want to draft an email to a client explaining the benefits of adding a critical illness rider to their life insurance policy. My current prompt is: 'Write an email about adding a critical illness rider.' Do you have suggestions to improve this prompt for more detailed and persuasive content?```\n",
    "\n",
    "Possible AI Suggestion:\n",
    "\n",
    "```To enhance your prompt, you might include details about the client's situation and the specific benefits they might value. For example: 'Draft a persuasive email to a 40-year-old client with a family history of illness, explaining how adding a critical illness rider to their existing life insurance policy can provide financial security in case of serious health issues.'```\n",
    "\n",
    "The AI's suggestion adds specificity, which can lead to a more tailored and impactful email.\n",
    "\n",
    "### Concerns of Bias\n",
    "\n",
    "Prompt engineering can be strategically used to decrease bias in AI-generated responses by carefully designing prompts that promote fairness and neutrality. By explicitly instructing the AI to avoid stereotypes, consider diverse perspectives, and use inclusive language, users can mitigate unintended biases that may exist in the model's training data. For instance, a life insurance professional might craft prompts that request policy recommendations without referencing demographic factors like age, gender, or ethnicity unless relevant and appropriate. By being mindful of the instructions given to the AI and specifying the need for unbiased and equitable information, prompt engineering becomes a valuable tool in producing fair and balanced outputs.\n",
    "\n",
    "### Next Steps\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "anaconda-cloud": {},
  "colab": {
   "provenance": []
  },
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
